﻿<Page
    x:Class="Ganjine_Windows10.Search"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Ganjine_Windows10"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    FlowDirection="RightToLeft"
    DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
    mc:Ignorable="d" Loaded="Page_Loaded"
    GotFocus="pageRoot_GotFocus" LostFocus="pageRoot_LostFocus" SizeChanged="Page_SizeChanged">

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup>
                <VisualState x:Name="wideView">
                    <VisualState.StateTriggers>
                        <AdaptiveTrigger MinWindowWidth="700" />
                    </VisualState.StateTriggers>
                    <VisualState.Setters>
                        <Setter Target="MainView.IsPaneOpen" Value="True"/>
                        <Setter Target="MainView.DisplayMode" Value="Inline"/>
                        <Setter Target="MainView.FlowDirection" Value="LeftToRight"/>

                        <Setter Target="SearchBar.HorizontalAlignment" Value="Right"/>
                        <Setter Target="SearchBar.Width" Value="350"/>
                        <Setter Target="SearchBar.Visibility" Value="Visible"/>
                        <Setter Target="HeaderRowDefinition.Height" Value="70"/>
                        <Setter Target="HeaderRelPanel1.Margin" Value="10,15,0,0"/>
                        <Setter Target="SearchBar.Margin" Value="60,10,0,10"/>

                        <Setter Target="headerText.Visibility" Value="Visible"/>
                        <Setter Target="BackToggle.Visibility" Value="Visible"/>
                        <Setter Target="MenuToggle.Visibility" Value="Collapsed"/>
                    </VisualState.Setters>
                </VisualState>
                <VisualState x:Name="narrowView">
                    <VisualState.Setters>
                        <Setter Target="MainView.IsPaneOpen" Value="False"/>
                        <Setter Target="MainView.DisplayMode" Value="Overlay"/>
                        <Setter Target="MainView.FlowDirection" Value="RightToLeft"/>
                        
                        
                        <Setter Target="SearchBar.HorizontalAlignment" Value="Stretch"/>
                        <Setter Target="SearchBar.Width" Value="Auto"/>
                        <Setter Target="SearchBar.Visibility" Value="Visible"/>
                        <Setter Target="HeaderRowDefinition.Height" Value="50"/>
                        <Setter Target="HeaderRelPanel1.Margin" Value="0,5,0,0"/>
                        <Setter Target="SearchBar.Margin" Value="60,0,0,0"/>

                        <Setter Target="headerText.Visibility" Value="Collapsed"/>
                        <Setter Target="BackToggle.Visibility" Value="Collapsed"/>
                        <Setter Target="MenuToggle.Visibility" Value="Visible"/>
                    </VisualState.Setters>
                    <VisualState.StateTriggers>
                        <AdaptiveTrigger MinWindowWidth="0" />
                    </VisualState.StateTriggers>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>


        <Grid.RowDefinitions>
            <RowDefinition Height="70" x:Name="HeaderRowDefinition" />
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Grid Grid.Row="0" x:Name="Header" Background="{StaticResource HeaderColor}">
            <RelativePanel Margin="10,15,0,0" x:Name="HeaderRelPanel1" >
                <Button x:Name="BackToggle" Visibility="Visible" 
                      Background="Transparent" Click="BackToggle_Click">
                    <FontIcon  
                              FontFamily="Segoe MDL2 Assets"  
                         Foreground="{ThemeResource AppBarItemForegroundThemeBrush}"  
                         Glyph="&#xE0AD;" FontSize="30" />
                </Button>
                <Button x:Name="MenuToggle"   
                      Background="Transparent" RelativePanel.RightOf="BackToggle" Click="MenuToggle_Click">
                    <FontIcon 
                              FontFamily="Segoe MDL2 Assets"  
                         Foreground="{ThemeResource AppBarItemForegroundThemeBrush}"  
                         Glyph="&#xE700;" FontSize="30" />
                </Button>
                <TextBlock x:Name="headerText" FontFamily="/Fonts/Yekan.otf#B Yekan" HorizontalAlignment="Left" TextWrapping="Wrap" Text="جست‌و‌جو" RelativePanel.RightOf="BackToggle" FontSize="30" VerticalAlignment="Bottom" Margin="10,0,0,0"/>
            </RelativePanel>
            <Grid HorizontalAlignment="Right" Width="400" x:Name="SearchBar" Margin="60,10,0,10">
                <TextBox Margin="5,5,55,5" FlowDirection="RightToLeft" Text="{Binding SearchTerm}" x:Name="SearchTextBox" KeyUp="SearchTextBox_KeyUp" TextChanged="SearchTextBox_TextChanged" />
                <Button x:Name="SearchButton"   Margin="5,5,5,5" HorizontalAlignment="Right"
                      Background="Transparent" Click="SearchButton_Click">
                    <FontIcon x:Name="SearchButtonIcon"  
                              FontFamily="Segoe MDL2 Assets"  
                         Foreground="{ThemeResource AppBarItemForegroundThemeBrush}"  
                         Glyph="&#xE094;" FontSize="28" />
                </Button>
            </Grid>
        </Grid>
        <Grid Grid.Row="1">
            <SplitView x:Name="MainView" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0,0,0,0" DisplayMode="Inline" IsPaneOpen="True">
                <SplitView.Pane>
                    <Grid Background="{StaticResource SideBarColor}" FlowDirection="RightToLeft">

                        <ListView x:Name="searchSource" 
                                  AutomationProperties.AutomationId="ItemListViewSection5"
                                  AutomationProperties.Name="Items In Group"
                                  SelectionMode="Single"
                                  IsItemClickEnabled="True"
                                  Padding="20"
                                  ItemsSource="{Binding Poets}"
                                  Grid.RowSpan="2" ItemClick="searchSource_ItemClick">
                            <ListView.Resources>
                                <Style TargetType="ListViewItem">
                                    <Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}" />
                                    <Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}" />
                                    <Setter Property="Background" Value="Transparent"/>
                                    <Setter Property="TabNavigation" Value="Local"/>
                                    <Setter Property="IsHoldingEnabled" Value="True"/>
                                    <Setter Property="Margin" Value="0,0,18,2"/>
                                    <Setter Property="HorizontalContentAlignment" Value="Left"/>
                                    <Setter Property="VerticalContentAlignment" Value="Top"/>
                                    <Setter Property="Template">
                                        <Setter.Value>
                                            <ControlTemplate TargetType="ListViewItem">
                                                <ListViewItemPresenter
                        ContentTransitions="{TemplateBinding ContentTransitions}"
                        Padding="10,10,10,10"
                        SelectionCheckMarkVisualEnabled="True"
                        CheckHintBrush="{ThemeResource ListViewItemCheckHintThemeBrush}"
                        CheckSelectingBrush="{ThemeResource ListViewItemCheckSelectingThemeBrush}"
                        CheckBrush="{ThemeResource ListViewItemCheckThemeBrush}"
                        DragBackground="{ThemeResource ListViewItemDragBackgroundThemeBrush}"
                        DragForeground="{ThemeResource ListViewItemDragForegroundThemeBrush}"
                        FocusBorderBrush="{ThemeResource ListViewItemFocusBorderThemeBrush}"
                        PlaceholderBackground="{ThemeResource ListViewItemPlaceholderBackgroundThemeBrush}"
                        PointerOverBackground="{ThemeResource ListViewItemPointerOverBackgroundThemeBrush}"
                        SelectedBorderThickness="{ThemeResource ListViewItemCompactSelectedBorderThemeThickness}"
                        SelectedBackground="LightGreen"
                        SelectedForeground="{ThemeResource ListViewItemSelectedForegroundThemeBrush}"
                        SelectedPointerOverBackground="LightGreen"
                        SelectedPointerOverBorderBrush="Green"
                        DisabledOpacity="{ThemeResource ListViewItemDisabledThemeOpacity}"
                        DragOpacity="{ThemeResource ListViewItemDragThemeOpacity}"
                        ReorderHintOffset="{ThemeResource ListViewItemReorderHintThemeOffset}"
                        HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                        VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                        PointerOverBackgroundMargin="1"
                        ContentMargin="4" FontSize="20" />
                                            </ControlTemplate>
                                        </Setter.Value>
                                    </Setter>
                                </Style>
                            </ListView.Resources>
                        </ListView>
                    </Grid>
                </SplitView.Pane>
                <Grid FlowDirection="RightToLeft">


                    <ListView
                    Background="White"
                    x:Name="resultsListView"
                    AutomationProperties.Name="Search Results"
                    TabIndex="1"
                    Grid.Row="1"
                    Margin="0,0,0,0"
                    Padding="20,20,20,0"
                    SelectionMode="None"
                    IsItemClickEnabled="True"
                    ItemClick="resultsListView_ItemClick">
                        <ListView.ItemTemplate>
                            <DataTemplate>
                                <Grid Margin="0,0,0,0">
                                    <Grid Height="90" Margin="0" HorizontalAlignment="Stretch">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="*"/>
                                        </Grid.ColumnDefinitions>
                                        <StackPanel Grid.Column="1" VerticalAlignment="Center" Margin="0,5,0,5">
                                            <TextBlock Margin="0,0,0,10" VerticalAlignment="Center" HorizontalAlignment="Stretch" TextAlignment="Left" Text="{Binding Text}" Style="{StaticResource TitleTextBlockStyle}" TextWrapping="NoWrap" FontSize="26"/>
                                            <TextBlock Margin="5,0,0,5" VerticalAlignment="Center" HorizontalAlignment="Stretch" TextAlignment="Left" Text="{Binding s1}" Style="{StaticResource CaptionTextBlockStyle}" TextWrapping="NoWrap" FontSize="14" Opacity="0.8" FontWeight="Thin" FontFamily="Segoe UI Light"/>
                                        </StackPanel>
                                    </Grid>
                                </Grid>
                            </DataTemplate>
                        </ListView.ItemTemplate>
                    </ListView>

                    <TextBlock x:Name="NoResults"
                               Grid.Row="1"
                               Margin="30,30,0,0"
                               Visibility="Collapsed"
                               Style="{StaticResource SubheaderTextBlockStyle}"
                               Text="موردی یافت نشد." >

                    </TextBlock>
                </Grid>

            </SplitView>
            <ProgressBar VerticalAlignment="Top" Visibility="Collapsed" x:Name="searchProgressBar2" IsIndeterminate="True" />
            <ProgressBar VerticalAlignment="Top" Visibility="Collapsed" x:Name="searchProgressBar" IsIndeterminate="False" />
            
        </Grid>

    </Grid>
</Page>
